home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / osi / isode / vmsisode / vmsisode80_tar.Z / vmsisode80_tar / sockit / gccinclude / stdio.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-13  |  2.0 KB  |  93 lines

  1. /*
  2.  *    This defines a VAX-11 "C" runtime compatible stdio interface
  3.  */
  4. #ifndef __STDIO_DEFINED
  5. #define __STDIO_DEFINED
  6.  
  7. /*
  8.  *    The maximum number of files we can have open at a time
  9.  */
  10. #define _NFILE 20
  11.  
  12. /*
  13.  *    STDIO buffer size (sure wish it could be 1Kb)
  14.  */
  15. #define BUFSIZ 512
  16. /* # define _IONBF 0 */
  17. # define _IOLBF 1
  18. # define _IOFBF 2
  19.  
  20. #define    _IOREAD        0x01
  21. #define    _IOWRT        0x02
  22. #define    _IONBF        0x04
  23. #define    _IOMYBUF    0x08
  24. #define    _IOEOF        0x10
  25. #define    _IOERR        0x20
  26. #define    _IOSTRG        0x40
  27. #define _IORW        0x80
  28.  
  29.  
  30. /*
  31.  *    This is what the VAX-11 "C" runtime stdio FILE structure looks like
  32.  */
  33. struct    _iobuf     {
  34.     int    _cnt;            /* # of characters in the buffer */
  35.     char    *_ptr;            /* Pointer into the buffer     */
  36.     char    *_base;            /* Pointer to start of buffer     */
  37.     char    _flag;            /* STDIO flags             */
  38.     char    _file;            /* File descriptor         */
  39.     };
  40.  
  41. /*
  42.  *    Instead of passing around pointers to _iobuf structures, VAX-11 "C"
  43.  *    passes around pointers to pointers.
  44.  */
  45. typedef struct _iobuf *FILE;
  46.  
  47. /*
  48.  *    Also, stdin/stdout/stderr need to be defined
  49.  *    [We also use a hack here that makes the GCC assembler modify
  50.  *     the psect attributes to match those of the VAX-11 "C" runtime]
  51.  */
  52. #ifdef vax11c
  53. extern noshare FILE *stdin, *stdout, *stderr;
  54. #else
  55. #define    stdin    $$PsectAttributes_NOSHR$$stdin
  56. #define    stdout    $$PsectAttributes_NOSHR$$stdout
  57. #define    stderr    $$PsectAttributes_NOSHR$$stderr
  58. extern FILE *stdin;
  59. extern FILE *stdout;
  60. extern FILE *stderr;
  61. #endif
  62.  
  63. /*
  64.  *    Define NULL and EOF
  65.  */
  66. #define    NULL        0
  67. #define    EOF        (-1)
  68.  
  69. /*
  70.  *    Define the stdio macros
  71.  */
  72. #define getc(p)        fgetc(p)
  73. #define getchar()    fgetc(stdin)
  74. #define putc(x,p)    fputc(x,p)
  75. #define putchar(x)    fputc(x,stdout)
  76. #define feof(p)        (((*p)->_flag&_IOEOF)!=0)
  77. #define ferror(p)    (p == stdout) ? 0 : (((*p)->_flag&_IOERR)!=0)
  78. #define fileno(p)    ((*p)->_file)
  79. #define clearerr(p)    ((*p)->_flag &= ~(_IOERR|_IOEOF))
  80.  
  81. /*
  82.  *    Declare stdio routines
  83.  */
  84. FILE    *fopen();
  85. FILE    *fdopen();
  86. FILE    *freopen();
  87. char    *fgets();
  88. long    ftell();
  89.  
  90. #define random rand
  91. #define srandom srand
  92. #endif    __STDIO_DEFINED
  93.